
import 'package:dio/dio.dart';
import 'package:wechat_manager/network/api/base_service.dart';
import 'package:wechat_manager/network/api/content_service.dart';
import 'package:wechat_manager/network/api/material_service.dart';
import 'package:wechat_manager/network/interceptors/request_interceptor.dart';
import 'package:wechat_manager/network/interceptors/response_interceptor.dart';
import 'package:wechat_manager/network/network_info.dart';

class NetworkHelper {
  static NetworkHelper INSTANCE = NetworkHelper._();

  late Dio _dio;
  late BaseService baseService;
  late ContentService contentService;
  late MaterialService materialService;

  NetworkHelper._() {
    var dioOptions = BaseOptions(
      baseUrl: NetworkInfo.BASE_URL,
      connectTimeout: Duration(seconds: 45),
      headers: {
        "Content-Type": "application/json",
      },
    );

    _dio = Dio(dioOptions);
    _dio.interceptors.add(RequestInterceptor());
    _dio.interceptors.add(ResponseInterceptor());
    _dio.interceptors.add(LogInterceptor(requestBody: true,responseBody: true));

    baseService = BaseService(_dio);
    contentService = ContentService(_dio);
    materialService = MaterialService(_dio);

  }

}